//
//  YHEmotionButton.swift
//  EmotionKeyboard
//
//  Created by 昱含 on 16/5/31.
//  Copyright © 2016年 YuHan. All rights reserved.
//

import UIKit

class YHEmotionButton: UIButton {
    
    var emotion: YHEmotions? {
        didSet{
           if let imagePath = emotion?.imagePath {
                setImage(UIImage(named: imagePath), forState: .Normal)
                setTitle(nil, forState: .Normal)
           }else{
            if let title = emotion?.emoji {
                setTitle(title, forState: .Normal)
                setImage(nil, forState: .Normal)
            }
          }
            
            if emotion!.isDelete {
                setImage(UIImage(named: "compose_emotion_delete"), forState: .Normal)
                backgroundColor = UIColor.whiteColor()
            }
            
            if emotion!.isEmpty {
                setTitle(nil, forState: .Normal)
                setImage(nil, forState: .Normal)
            }
        }
    }
}
